import { Loading } from 'element-ui'

const state = {
  loading: false
}

const mutations = {
  SET_LOADING: (state) => {
    state.loading = Loading.service({
      fullscreen: false,
      lock: false,
      text: '正在拼命加载中',
      spinner: 'el-icon-loading'
    })
  },
  SET_HIDELOADING: (state) => {
    state.loading = state.loading.close()
  }
}

const actions = {
  showLoading({ commit }, obj) {
    commit('SET_LOADING')
  },
  hideLoading({ commit }, obj) {
    commit('SET_HIDELOADING')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
